package com.jm.api.system;

import com.jm.common.bean.base.PageParam;
import com.jm.common.bean.base.PageVO;
import com.jm.common.conf.api.ApiResult;
import com.jm.constant.SysApiConstant;
import com.jm.model.system.Pl;
import com.jm.service.i.system.PlService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author kong
 * @since 2023-06-25
 */
@RestController
@Tag(name = "选手管理")
@RequestMapping(SysApiConstant.OPEN_API + "pl")
public class PlApi {
    private final PlService plService;

    @Autowired
    public PlApi(PlService plService) {
        this.plService = plService;
    }

    @PostMapping("/page")
    @ApiResult
    @Operation(summary = "列表分页查询")
    public PageVO<Pl> page(@Validated @RequestBody PageParam param) {
        return this.plService.page(param);
    }

    @GetMapping("/get/{id}")
    @ApiResult
    @Operation(summary = "详情查询")
    public Pl get(@PathVariable("id") String id) {
        return this.plService.get(id);
    }

    @PostMapping("/save")
    @ApiResult
    @Operation(summary = "保存")
    public Boolean save(@RequestBody Pl pl) {
        return this.plService.add(pl);
    }


    @PostMapping("/modify")
    @ApiResult
    @Operation(summary = "修改")
    public Boolean modify(@RequestBody Pl pl) {
        return this.plService.modify(pl);
    }


    @PostMapping("/del")
    @ApiResult
    @Operation(summary = "删除")
    public Boolean delete(@RequestBody List<String> ids) {
        return this.plService.del(ids);
    }
}